﻿@{
    ViewBag.Title = " 兑礼网控制中心-兑换统计";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Content/js/highcharts.js"></script>
@*<label>时间段</label>*@
@*<input id="begintime" class="easyui-datebox" editable="false" value="@DateTime.Now.ToString("yyyy-MM-01")">—
<input id="endtime" class="easyui-datebox" editable="false" value="@DateTime.Now.AddMonths(1).ToString("yyyy-MM-01")">*@
@*<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-search" plain="true" data-options="onClick:search">搜索</a>*@
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="searchs(parseInt('@((int)ExChange.Web.EnumHelper.Tongji.本周)'))">本周</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="searchs(parseInt('@((int)ExChange.Web.EnumHelper.Tongji.本月)'))">本月</a>
@*<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="thisthreemonth()">本季</a>*@
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="searchs(parseInt('@((int)ExChange.Web.EnumHelper.Tongji.本年)'))">本年</a>

<div id="container" style="min-width:400px;height:400px">
</div>

<script>
    $(function () {
        $.post("@Url.Action("GetData", "Order")", function (data) {
            tongji(data.data, data.type, data.text, data.total);
        });
    });


    function searchs(type)
    {
        $.post("@Url.Action("GetData", "Order")",{type:type}, function (data) {
            tongji(data.data, data.type, data.text, data.total);
        });
    }

    function tongji(data, type, text, total) {
        $('#container').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: '兑换统计(' + text + '【' + total + '】次)'
            },
            subtitle: {
                //text: '数据来源: WorldClimate.com'
            },
            xAxis: {
                categories: type,
                //[
                //    '一月',
                //    '二月',
                //    '三月',
                //    '四月',
                //    '五月',
                //    '六月',
                //    '七月',
                //    '八月',
                //    '九月',
                //    '十月',
                //    '十一月',
                //    '十二月'
                //],
                crosshair: true
            },
            yAxis: {
                min: 0,
                title: {
                    text: '兑换数量(次)'
                }
            },
            tooltip: {
                headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                '<td style="padding:0"><b>{point.y:.1f} 个</b></td></tr>',
                footerFormat: '</table>',
                shared: true,
                useHTML: true
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            },
            series: [{
                name: '已兑换数量',
                data: data
            }, ]
        });
    }


    @*function thisthreemonth() {
        var time = '@DateTime.Now.Month';
        if (time == '1' || time == '2' || time == '3') {
            var begintime = $("#begintime").datebox('setValue', '@DateTime.Now.ToString("yyyy-01-01")');
            $("#endtime").datebox('setValue', '@DateTime.Now.ToString("yyyy-04-01")');
        }
        if (time == '4' || time == '5' || time == '6') {
            $("#begintime").datebox('setValue', '@DateTime.Now.ToString("yyyy-04-01")');
            $("#endtime").datebox('setValue', '@DateTime.Now.ToString("yyyy-07-01")');
        }
        if (time == '7' || time == '8' || time == '9') {
            $("#begintime").datebox('setValue', '@DateTime.Now.ToString("yyyy-07-01")');
            $("#endtime").datebox('setValue', '@DateTime.Now.ToString("yyyy-10-01")');
        }
        if (time == '10' || time == '11' || time == '12') {
            $("#begintime").datebox('setValue', '@DateTime.Now.ToString("yyyy-10-01")');
            $("#endtime").datebox('setValue', '@DateTime.Now.AddYears(1).ToString("yyyy-01-01")');
        }
        search();
    }


    function thisyear() {
        $("#begintime").datebox('setValue', '@DateTime.Now.ToString("yyyy-01-01")');
        $("#endtime").datebox('setValue', '@DateTime.Now.AddYears(1).ToString("yyyy-01-01")');
        search();
    }*@
</script>